package com.example.mybatisplus.web.controller;

import com.example.mybatisplus.mapper.HCommentMapper;
import com.example.mybatisplus.model.dto.CommentDto;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.HCommentService;
import com.example.mybatisplus.model.domain.HComment;

import java.util.List;


/**
 * 前端控制器
 *
 * @author yfy
 * @version v1.0
 * @since 2022-01-04
 */
@RestController
@RequestMapping("/api/hComment")
public class HCommentController {

    private final Logger logger = LoggerFactory.getLogger(HCommentController.class);

    @Autowired
    private HCommentService hCommentService;
    @Autowired
    private HCommentMapper commentMapper;

    @GetMapping("/comment")
    public JsonResponse hotelComment(Long id) {
        List<HComment> comments = commentMapper.selectHotelComment(id);
        return JsonResponse.success(comments);
    }

    @GetMapping("/hotelComment")
    public JsonResponse hotelComment(HComment comment) {
        commentMapper.insert(comment);
        return JsonResponse.success(comment);
    }
}

